﻿using System;

namespace PatternStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            //Uri uri = new Uri("http://baidu.com");

            //Console.WriteLine(ShouldAllow(uri));

          Console.WriteLine(AverageCelsiusTemperature(Season.Spring, true));
        }

        //可以用于判断
        static bool ShouldAllow(Uri uri) => uri switch
        {

            { Scheme: "http", Port: 80 } => true,
            { Scheme: "https", Port: 443 } => true,
            { Scheme: "ftp", Port: 21 } => true,
            { IsLoopback: true } => true,
            _ => false
        };

        static int AverageCelsiusTemperature(Season season, bool dayTime) => (season, dayTime) switch
        {
            (Season.Spring, true) => 20,
            (Season.Spring, false) => 16,
            (Season.Summer, true) => 27,
            (Season.Summer, false) => 22,
            (Season.Fall, true) => 18,
            (Season.Fall, false) => 12,
            (Season.Winter, true) => 10,
            (Season.Winter, false) => -2,
            _ => throw new Exception("Unexpected combination")
        };



    }

    enum Season
    {
        Spring,
        Summer,
        Fall,
        Winter
    }
}
